package com.khong.sale.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.khong.sale.R;
import com.khong.sale.entity.GridItem;
import com.khong.sale.entity.OrderDetail;

public class OrderDetailAdapter extends BaseAdapter {
	private Context mContext;
	private List<OrderDetail> list;
	private LayoutInflater inflater;

	public OrderDetailAdapter(Context cotext, List<OrderDetail> list) {
		this.mContext = cotext;
		this.list = list;
		inflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Hoder hoder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.order_detail_item, null);
			hoder = new Hoder();
			hoder.num = (TextView) convertView.findViewById(R.id.detail_num);
			hoder.name = (TextView) convertView.findViewById(R.id.detail_name);
			hoder.size = (TextView) convertView.findViewById(R.id.detail_size);
			hoder.money = (TextView) convertView.findViewById(R.id.detail_money);
		} else {
			hoder = (Hoder) convertView.getTag();
		}
		OrderDetail item = list.get(position);
		hoder.num.setText(item.getNum());
		hoder.name.setText(item.getName());
		hoder.size.setText(item.getSize());
		hoder.money.setText(item.getMoney());
		convertView.setTag(hoder);
		return convertView;
	}

	class Hoder {
		TextView num;
		TextView name;
		TextView size;
		TextView money;
	}

}
